﻿<Window Name="mainWindow" x:Class="PlayRandom.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:conv="clr-namespace:PlayRandom.Converters"
        xmlns:convUtil="clr-namespace:CommonUtilities.Converters;assembly=CommonUtilities"
        xmlns:cutil="clr-namespace:CommonUtilities.Controls;assembly=CommonUtilities" 
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="Play me something" MinHeight="450" MinWidth="750" Height="450" Width="750" SizeToContent="Width" Background="Wheat"
        WindowStartupLocation="CenterScreen" Icon="/PlayRandom;component/Resources/heart_black.ico" Loaded="mainWindow_Loaded" PreviewKeyDown="mainWindow_PreviewKeyDown">

    <Window.InputBindings>
        <KeyBinding Modifiers="Control" Key="R" Command="{Binding PlayRandomCommand}" />
        <KeyBinding Modifiers="Control" Key="Enter" Command="{Binding PlaySelectedRandomCommand}" />
        <KeyBinding Modifiers="Control" Key="F2" Command="{Binding AddSelectedRandomToFavCommand}" />
        <KeyBinding Modifiers="Control" Key="D" Command="{Binding DeleteSelectedRandomCommand}" />

        <KeyBinding Modifiers="Control" Key="L" Command="{Binding ListFavCommand}" />
        <KeyBinding Modifiers="Control" Key="F" Command="{Binding PlayFavCommand}" />
        <KeyBinding Key="F2" Command="{Binding RenameFavCommand}" />
        <KeyBinding Modifiers="Control" Key="Delete" Command="{Binding DeleteFavCommand}" />

        <KeyBinding Modifiers="Control" Key="S" Command="{Binding OpenSettingsCommand}" />
        <KeyBinding Modifiers="Control" Key="E" Command="{Binding SearchFavFocusCommand}" />
    </Window.InputBindings>
    <Window.Resources>
        <sys:String x:Key="HeartSign">&#x2665;</sys:String>

        <convUtil:VisibilityConverter x:Key="VisibilityConverter" />
        <conv:FileSizeConverter x:Key="FileSizeConverter" />
        <conv:GroupedFavouritesConverter x:Key="GroupedFavouritesConverter" />
        <conv:FavTextRedConverter x:Key="FavTextRedConverter" />

        <Style x:Key="RepeatorItemBorderStyle" TargetType="Border">
            <Setter Property="Margin" Value="5,0" />
            <Setter Property="Padding" Value="5,0" />
            <Setter Property="BorderBrush" Value="{DynamicResource SelectedItemBorderBrush}" />
            <Setter Property="BorderThickness" Value="0.5,0,0,0.5" />
            <Setter Property="CornerRadius" Value="5" />
            <Setter Property="SnapsToDevicePixels" Value="true" />
        </Style>

        <Style TargetType="Button">
            <Setter Property="Height" Value="23" />
            <Setter Property="Padding" Value="10,0" />
        </Style>

        <LinearGradientBrush x:Key="SelectedItemBorderBrush" StartPoint="0,0.75" EndPoint="0.75,1">
            <GradientStop Color="Black" Offset="0.5" />
            <GradientStop Color="Transparent" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="HoverItemBrush" StartPoint="0,0.75" EndPoint="0.75,1">
            <GradientStop Color="LightGray" Offset="0.5" />
            <GradientStop Color="Transparent" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="SelectedItemBrush" StartPoint="0,0.75" EndPoint="0.75,1">
            <GradientStop Color="Yellow" Offset="0.5" />
            <GradientStop Color="Transparent" Offset="1" />
        </LinearGradientBrush>

        <Style x:Key="_ComboBoxItemStyle" TargetType="ComboBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ComboBoxItem">
                        <Border Name="_Border" Style="{DynamicResource RepeatorItemBorderStyle}">
                            <ContentPresenter Margin="1.5" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="_Border" Property="Background" Value="{DynamicResource SelectedItemBrush}" />
                                <Setter Property="Foreground" Value="Red" />
                                <Setter Property="FontWeight" Value="Bold" />
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="_Border" Property="Background" Value="{DynamicResource HoverItemBrush}" />
                                <Setter Property="Foreground" Value="Black" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="_ListBoxItemStyle" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border Name="_Border" Style="{DynamicResource RepeatorItemBorderStyle}">
                            <ContentPresenter Margin="1" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="_Border" Property="Background" Value="{DynamicResource SelectedItemBrush}" />
                                <Setter Property="Foreground" Value="Red" />
                                <Setter Property="FontWeight" Value="Bold" />
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="_Border" Property="Background" Value="{DynamicResource HoverItemBrush}" />
                                <Setter Property="Foreground" Value="Black" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="ComboBox">
            <Setter Property="ItemContainerStyle" Value="{DynamicResource _ComboBoxItemStyle}" />
        </Style>

        <Style TargetType="ListBox">
            <Setter Property="ItemContainerStyle" Value="{DynamicResource _ListBoxItemStyle}" />
        </Style>
    </Window.Resources>

    <toolkit:BusyIndicator DisplayAfter="00:00:00" IsBusy="{Binding IsBusy}">
        <Grid Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Grid Name="grdRandomFile" Grid.Row="0" Margin="0,3" Height="23">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <ComboBox Name="cmbDirPath" Grid.ColumnSpan="2" Margin="1.5,0" Padding="5,0" VerticalAlignment="Stretch" VerticalContentAlignment="Center" 
                          ItemContainerStyle="{DynamicResource _ComboBoxItemStyle}" ItemsSource="{Binding AllPaths}" 
                          SelectedValuePath="Key" SelectedValue="{Binding DirPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                          Visibility="{Binding ElementName=tglAddPath, Path=IsChecked, Converter={StaticResource VisibilityConverter}, ConverterParameter=-}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Padding="5,0" Text="{Binding Key}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <TextBox Name="txtDirPath" Margin="3,0" Background="Transparent" VerticalAlignment="Center" 
                         Text="{Binding DirPathAdded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                         Visibility="{Binding ElementName=tglAddPath, Path=IsChecked, Converter={StaticResource VisibilityConverter}}">
                    <TextBox.BorderBrush>
                        <LinearGradientBrush StartPoint="0,0.75" EndPoint="0.75,1">
                            <GradientStop Color="Blue" Offset="0.5" />
                            <GradientStop Color="Transparent" Offset="1" />
                        </LinearGradientBrush>
                    </TextBox.BorderBrush>
                </TextBox>
                <Button Name="btnBrowse" Grid.Column="1" Padding="1,0" Width="{Binding ElementName=btnBrowse, Path=ActualHeight}" Content=".." Command="{Binding BrowseCommand}" 
                        Visibility="{Binding ElementName=tglAddPath, Path=IsChecked, Converter={StaticResource VisibilityConverter}}">
                    <Button.BorderBrush>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="Transparent" Offset="0" />
                            <GradientStop Color="Blue" Offset="1" />
                        </LinearGradientBrush>
                    </Button.BorderBrush>
                </Button>
                <ToggleButton Name="tglAddPath" Grid.Column="2" Width="{Binding ElementName=tglAddPath, Path=ActualHeight}" VerticalContentAlignment="Top" 
                              FontWeight="ExtraBold" Foreground="Green" FontSize="12" BorderBrush="{Binding ElementName=tglAddPath, Path=Foreground}" IsEnabled="{Binding IsAddPathEnabled}" 
                              IsChecked="{Binding IsAddPathChecked, Mode=TwoWay}" Content="{Binding AddPathContent, FallbackValue=+}" ToolTip="{Binding AddPathToolTip}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Checked">
                            <i:InvokeCommandAction Command="{Binding AddPathCommand}" />
                        </i:EventTrigger>
                        <i:EventTrigger EventName="Unchecked">
                            <i:InvokeCommandAction Command="{Binding AddPathCommand}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <ToggleButton.Background>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="Green" Offset="0" />
                            <GradientStop Color="Transparent" Offset="1" />
                        </LinearGradientBrush>
                    </ToggleButton.Background>
                </ToggleButton>
                <ToggleButton Name="tglDelPath" Grid.Column="3" Width="{Binding ElementName=tglDelPath, Path=ActualHeight}" VerticalContentAlignment="Top" 
                              FontWeight="Bold" Foreground="Red" BorderBrush="{Binding ElementName=tglDelPath, Path=Foreground}" 
                              IsChecked="{Binding IsDelPathChecked, Mode=TwoWay}" Content="X" ToolTip="Delete an existing path">
                    <ToggleButton.Background>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="Transparent" Offset="0" />
                            <GradientStop Color="Red" Offset="1" />
                        </LinearGradientBrush>
                    </ToggleButton.Background>
                </ToggleButton>
                <StackPanel Grid.Column="4" Margin="3,0" Orientation="Horizontal">
                    <TextBlock Name="txtbCount" Margin="1.5,0" Width="30" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Right" Text="{Binding FileCountText, FallbackValue=0}" />
                    <Button Name="btnPlayRandom" Margin="1.5,0" BorderBrush="Purple" BorderThickness="2" Foreground="Purple" FontWeight="Bold" 
                            IsEnabled="{Binding IsPlayRandomEnabled}" Content="_Take a pick" ToolTip="Play a random file (Ctrl+R)" Command="{Binding PlayRandomCommand}" />
                </StackPanel>
                <Button Name="btnOpenSettings" Grid.Column="5" Margin="1.5,0" Padding="2,0" Width="25" Background="White" 
                        Command="{Binding OpenSettingsCommand}" ToolTip="Settings (Ctrl+S)">
                    <Button.Template>
                        <ControlTemplate TargetType="Button">
                            <Border Background="White" BorderBrush="Purple" BorderThickness="1.5" CornerRadius="8">
                                <Image Margin="1.5" Stretch="Uniform" Source="/PlayRandom;component/Resources/settings.png" />
                            </Border>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
            </Grid>

            <Grid Name="grdSelectedRandomFile" Grid.Row="1" Margin="0,3" IsEnabled="{Binding ElementName=cmbFileName, Path=HasItems}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <ComboBox Name="cmbFileName" Margin="1.5,0" ItemsSource="{Binding AllRandomFiles}" 
                          SelectedItem="{Binding SelectedRandomFile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                          ToolTip="{Binding SelectedRandomFile.FilePath}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock ToolTip="{Binding FilePath}">
                                <TextBlock.Text>
                                    <MultiBinding StringFormat="{}{0} | {1}">
                                        <Binding Path="FileName" />
                                        <Binding Path="FileSize" Converter="{StaticResource FileSizeConverter}" />
                                    </MultiBinding>
                                </TextBlock.Text>
                            </TextBlock>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <Button Name="btnPlaySelectedRandom" Grid.Column="1" Margin="1.5,0" Content="_Play" ToolTip="Plays selected (Ctrl+Enter)" 
                        Command="{Binding PlaySelectedRandomCommand}" MouseEnter="SelectedRandom_MouseEnter" MouseLeave="SelectedRandom_MouseLeave">
                    <Button.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                            <GradientStop Color="Blue" Offset="0" />
                            <GradientStop Color="#CCCCFF" Offset="0.5" />
                            <GradientStop Color="Blue" Offset="1" />
                        </LinearGradientBrush>
                    </Button.Background>
                </Button>
                <Button Name="btnAddSelectedRandomToFav" Grid.Column="2" Margin="1.5,0" BorderBrush="Green" Content="_Rename" ToolTip="Add to favourites (Ctrl+F2)" 
                        Command="{Binding AddSelectedRandomToFavCommand}" MouseEnter="SelectedRandom_MouseEnter" MouseLeave="SelectedRandom_MouseLeave">
                    <Button.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                            <GradientStop Color="Green" Offset="0" />
                            <GradientStop Color="#CCCCFF" Offset="0.5" />
                            <GradientStop Color="Green" Offset="1" />
                        </LinearGradientBrush>
                    </Button.Background>
                </Button>
                <Button Name="btnDeleteSelectedRandom" Grid.Column="3" Margin="1.5,0" BorderBrush="Red" Content="_Delete" ToolTip="Deletes selected (Ctrl+D)" 
                        Command="{Binding DeleteSelectedRandomCommand}" MouseEnter="SelectedRandom_MouseEnter" MouseLeave="SelectedRandom_MouseLeave">
                    <Button.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                            <GradientStop Color="Red" Offset="0" />
                            <GradientStop Color="#CCCCFF" Offset="0.5" />
                            <GradientStop Color="Red" Offset="1" />
                        </LinearGradientBrush>
                    </Button.Background>
                </Button>
            </Grid>

            <ListBox Name="lstDelPth" Grid.Row="2" ItemsSource="{Binding AllPaths}" 
                     SelectedValue="{Binding SelectedDelPath, Mode=TwoWay}" SelectedValuePath="Key"
                     Visibility="{Binding ElementName=tglDelPath, Path=IsChecked, Converter={StaticResource VisibilityConverter}}" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0.5" Orientation="Horizontal">
                            <Button Name="btnDelPath" Margin="1.5,0" Height="15" Width="15" HorizontalAlignment="Right" VerticalAlignment="Center" BorderBrush="Red" Background="Red" 
                                    Command="{Binding DataContext.DelPathCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding Key}" ToolTip="Click to delete this path" />
                            <TextBlock Margin="1.5,0" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Key}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

            <Expander Name="expFavourites" Grid.Row="2" Margin="8,0" 
                      VerticalAlignment="Top" Panel.ZIndex="{x:Static sys:Int32.MaxValue}" 
                      Visibility="{Binding IsDelPathChecked, Converter={StaticResource VisibilityConverter}, ConverterParameter=-}" 
                      IsExpanded="{Binding IsExpandFavChecked, Mode=TwoWay}" />
            <GroupBox Name="grpFavourites" Grid.Row="2" Margin="0,2,0,0" BorderBrush="Red" 
                      Visibility="{Binding ElementName=tglDelPath, Path=IsChecked, Converter={StaticResource VisibilityConverter}, ConverterParameter=-}" >
                <GroupBox.Header>
                    <Label Margin="23,0,0,0" Padding="0" VerticalAlignment="Center" VerticalContentAlignment="Center" Foreground="Red" FontSize="12" FontWeight="Bold" 
                           Content="{Binding FavGroupHeaderText, Converter={StaticResource FavTextRedConverter}, ConverterParameter={StaticResource HeartSign}, FallbackValue='&#x2665; Favourites'}" />
                </GroupBox.Header>

                <Grid Name="grdFavourites">
                    <ToggleButton Name="tglExpandFav" Foreground="Gray" IsChecked="{Binding IsExpandFavChecked, Mode=TwoWay}" 
                                  Visibility="{Binding ElementName=tglExpandFav, Path=IsChecked, Converter={StaticResource VisibilityConverter}, ConverterParameter=-}">
                        <ToggleButton.Template>
                            <ControlTemplate>
                                <ContentPresenter>
                                    <ContentPresenter.Content>
                                        <Label HorizontalContentAlignment="Center" VerticalContentAlignment="Center" 
                                               Foreground="{TemplateBinding Foreground}" Content="Expand Favourites" />
                                    </ContentPresenter.Content>
                                </ContentPresenter>
                            </ControlTemplate>
                        </ToggleButton.Template>
                    </ToggleButton>

                    <Grid Margin="0,5,0,0" Visibility="{Binding IsExpandFavChecked, Converter={StaticResource VisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <StackPanel Grid.Column="0" Margin="3,0" HorizontalAlignment="Left" Orientation="Horizontal">
                            <Button Name="btnListFav" Padding="30,0" IsEnabled="{Binding IsListFavEnabled}" 
                                    ToolTip="Lists all favourites (Ctrl+L)" Command="{Binding ListFavCommand}"
                                    Content="{Binding ListFavText, Converter={StaticResource FavTextRedConverter}, ConverterParameter={StaticResource HeartSign}, FallbackValue='List favourites &#x2665;'}" />
                            <TextBlock Name="txtbFavCount" Margin="3,0" VerticalAlignment="Center" Foreground="Green" TextAlignment="Left" ToolTip="Remaining Unseen of Total favourite files"
                                       Visibility="{Binding ElementName=lstFavFiles, Path=HasItems, Converter={StaticResource VisibilityConverter}}">
                                <TextBlock.Text>
                                    <MultiBinding StringFormat="{}{0} / {1}">
                                        <Binding Path="RemFavCountText" TargetNullValue="0" />
                                        <Binding Path="FilteredFavCountText" FallbackValue="0" />
                                    </MultiBinding>
                                </TextBlock.Text>
                            </TextBlock>
                        </StackPanel>

                        <StackPanel Grid.Column="1" Margin="3,0" Orientation="Horizontal">
                            <Button Name="btnPlayFav" Margin="1.5,0" Padding="30,0" IsEnabled="{Binding IsPlayFavEnabled}"
                                    ToolTip="Plays a random favourite (Ctrl+F)" Command="{Binding PlayFavCommand}"
                                    Content="{Binding PickFavText, Converter={StaticResource FavTextRedConverter}, ConverterParameter={StaticResource HeartSign}, FallbackValue='Pick a fav &#x2665;'}">
                            </Button>
                            <Button Name="btnDeleteFav" Margin="1.5,0" Padding="30,0" IsEnabled="{Binding IsDeleteFavEnabled}" 
                                    Content="Delete fav" ToolTip="Deletes selected favourite.." Command="{Binding DeleteFavCommand}" />
                        </StackPanel>

                        <StackPanel Grid.Column="2" Margin="3,0" HorizontalAlignment="Right" Orientation="Horizontal">
                            <TextBlock Name="txtbFavFilteredCount" Margin="1.5,0" VerticalAlignment="Center" Foreground="Blue" TextAlignment="Center" 
                                       Visibility="{Binding HasFavourites, Converter={StaticResource VisibilityConverter}}" ToolTip="Filtered of Total favourite files">
                                <TextBlock.Text>
                                    <MultiBinding StringFormat="{}{0} / {1}">
                                        <Binding Path="FilteredFavCountText" TargetNullValue="0" />
                                        <Binding Path="FavCountText" FallbackValue="0" />
                                    </MultiBinding>
                                </TextBlock.Text>
                            </TextBlock>
                            <TextBox Name="txtSearch" Margin="1.5,0" Width="150" VerticalAlignment="Center" BorderBrush="Blue" BorderThickness="1"
                                     IsEnabled="{Binding HasFavourites}" TextAlignment="Left" ToolTip="Enter text to search (Ctrl+E)"
                                     Text="{Binding FileSearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        </StackPanel>

                        <ScrollViewer Name="scrlvwFavFiles" Grid.Row="1" Grid.ColumnSpan="3" Margin="3" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible"
                                      Visibility="{Binding AppSettings.FavouritesSettings.IsFavGrouped, Converter={StaticResource VisibilityConverter}, ConverterParameter=-}">
                            <ItemsControl Name="itmctrlFavFiles" Grid.Row="1" Grid.ColumnSpan="3" Margin="3" IsEnabled="{Binding ElementName=itmctrlFavFiles, Path=HasItems}" 
                                          ItemsSource="{Binding AllFavFiles_Filtered, Converter={StaticResource GroupedFavouritesConverter}}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Expander Header="{Binding Key}">
                                            <ListBox ItemsSource="{Binding Value}" 
                                                     SelectedItem="{Binding DataContext.SelectedFavFile, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}, Mode=TwoWay}">
                                                <i:Interaction.Triggers>
                                                    <i:EventTrigger EventName="MouseDoubleClick">
                                                        <i:InvokeCommandAction Command="{Binding DataContext.FavFilesMouseDoubleClickCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2, Mode=FindAncestor}}" />
                                                    </i:EventTrigger>
                                                </i:Interaction.Triggers>
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Cursor="Hand" Text="{Binding FileName}" Foreground="{Binding ForeColour}" ToolTip="{Binding FilePath}" />
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                                <!--<ListBox.ContextMenu>
                                                    <ContextMenu IsEnabled="False">
                                                        <MenuItem Name="mnuPlayFav" Header="Play" Cursor="Hand" Command="{Binding DataContext.FavFilesMouseDoubleClickCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" />
                                                        <MenuItem Name="mnuUpdateTimestamp" Header="Update Timestamp" Cursor="Hand" Command="{Binding DataContext.UpdateTimestampCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=3}}" />
                                                        <MenuItem Name="mnuCopyPath" Header="Copy path" Cursor="Hand" Command="{Binding DataContext.CopyPathCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}" />
                                                        <Separator />
                                                        <MenuItem Name="mnuDeleteFav" Foreground="Red" Cursor="Hand" Header="Delete favourite" Command="{Binding DataContext.DeleteFavCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2, Mode=FindAncestor}}" />
                                                        <Separator />
                                                        <MenuItem Name="mnuOpenFolder" Header="Open containing folder" Command="{Binding DataContext.FavOpenFolderCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2, Mode=FindAncestor}}" />
                                                        <MenuItem Name="mnuFavExport" Header="Export with timestamp" Command="{Binding DataContext.FavExportCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2, Mode=FindAncestor}}" 
                                                                  ToolTip="Copies to a specific with files renamed with timestamps" />
                                                    </ContextMenu>
                                                </ListBox.ContextMenu>-->
                                            </ListBox>
                                        </Expander>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>

                        <ListBox Name="lstFavFiles" Grid.Row="1" Grid.ColumnSpan="3" Margin="3" BorderBrush="Green" BorderThickness="1" 
                                 IsEnabled="{Binding ElementName=lstFavFiles, Path=HasItems}" 
                                 ItemsSource="{Binding AllFavFiles_Filtered}" 
                                 SelectedItem="{Binding SelectedFavFile, Mode=TwoWay}"
                                 Visibility="{Binding AppSettings.FavouritesSettings.IsFavGrouped, Converter={StaticResource VisibilityConverter}}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseDoubleClick">
                                    <i:InvokeCommandAction Command="{Binding FavFilesMouseDoubleClickCommand}" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                            <ListBox.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Name="mnuPlayFav" Header="Play" Cursor="Hand" Command="{Binding FavFilesMouseDoubleClickCommand}" />
                                    <MenuItem Name="mnuUpdateTimestamp" Header="Update Timestamp" Cursor="Hand" Command="{Binding UpdateTimestampCommand}" />
                                    <MenuItem Name="mnuCopyPath" Header="Copy path" Cursor="Hand" Command="{Binding CopyPathCommand}" />
                                    <Separator />
                                    <MenuItem Name="mnuRenameFav" Cursor="Hand" Header="Rename favourite (F2)" Command="{Binding RenameFavCommand}" />
                                    <MenuItem Name="mnuDeleteFav" Foreground="Red" Cursor="Hand" Header="Delete favourite (Ctrl+Del)" Command="{Binding DeleteFavCommand}" />
                                    <Separator />
                                    <MenuItem Name="mnuUseFolder" Header="Use this folder" Command="{Binding UseFolderCommand}" />
                                    <MenuItem Name="mnuOpenFolder" Header="Open containing folder" Command="{Binding FavOpenFolderCommand}" />
                                    <MenuItem Name="mnuFavExport" Header="Export with timestamp" Command="{Binding FavExportCommand}" 
                                              ToolTip="Copies to a specific with files renamed with timestamps" />
                                </ContextMenu>
                            </ListBox.ContextMenu>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Cursor="Hand" Text="{Binding FileName}" Foreground="{Binding ForeColour}" ToolTip="{Binding FilePath}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Grid>
                </Grid>
            </GroupBox>

            <StatusBar Grid.Row="3" Margin="-5,0,-5,-5" Background="Transparent">
                <StatusBarItem>
                    <TextBlock Name="stsMain" Padding="5,0" Text="{Binding StatusText}" />
                </StatusBarItem>
                <StatusBarItem HorizontalAlignment="Right">
                    <TextBlock Name="stsAddtnl" Padding="5,0" Text="{Binding StatusAddnlInfo}" />
                </StatusBarItem>
            </StatusBar>
        </Grid>
    </toolkit:BusyIndicator>
</Window>
